﻿////=================================================== 
//// 
//// 文件名 :MonitorGate 
//// 简介: 
//// 作者： 小钟
//// 日期：2009-7-13 9:20:45  
//// 
////====================================================

//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using GCELibrary.Current;
//using GCELibrary.Current.SmsMessage;
//using GCEVideoMonitor.DAL;
//using Newtonsoft.Json;
//namespace GCEVideoMonitor.BLL.Gate
//{
//    public class MonitorGate:GateBase
//    {

//        protected override UserBase LoadUserInfo(Model.Us_User user)
//        {
//            var simpleUser = base.LoadUserInfo(user);
//            simpleUser = FillMonitorUserInfo(user, (MonitorUser)simpleUser);
//            return simpleUser;
//        }

//        protected virtual UserBase FillMonitorUserInfo(Model.Us_User user, MonitorUser monitorUser)
//        {
//            var dc = dataContext;

//            var usMonitorUser = user.Us_MonitorUserList.FirstOrDefault();
//            if (usMonitorUser == null)
//                throw SiteInfo.Instance.WarnFactory.CreateWarn("用户信息不完整");
//            monitorUser.MonitorRight = SiteInfo.Instance.GetMonitorRightByUserId(monitorUser.UserID);
//            monitorUser.DeviceRight = SiteInfo.Instance.GetDeviceRightByUserId(monitorUser.UserID);
//            monitorUser.OpenLoginSms = usMonitorUser.LoginMsg;
//            //个性化信息
//            var personality = usMonitorUser.Personality;
//            if (personality != null)
//            {
//                monitorUser.Personality = JsonConvert.DeserializeObject<MonitorUserPersonality>(personality);
//            }
//            else
//            {
//                monitorUser.Personality = new MonitorUserPersonality();
//                usMonitorUser.Personality = JsonConvert.SerializeObject(monitorUser.Personality);
//                dc.SaveChanges();
//            }
//            //发送登录短信
//            if (monitorUser.OpenLoginSms)
//            {
//                string content=string.Format(BLL.SiteInfo.Instance.SystemConfig.LoginSmsTemplate,
//                     monitorUser.Account, DateTime.Now);
//                var sendResult = GCELibrary.Current.SmsMessage.SmsHelper.SendMsg(content, monitorUser.Mobile);

//                dc.Us_SMS.InsertOnSubmit(new GCEVideoMonitor.Model.Us_SMS()
//                {
//                    IsPart = false,
//                    Content = content,
//                    IsAuto = true,
//                    ReceiverId = monitorUser.UserID,
//                    ReceiverNum = monitorUser.Mobile,
//                    Status = sendResult ? 1 : -1,
//                    ReceiverType = 1,
//                    SendTime = DateTime.Now,
                     
//                });
//                dc.SaveChanges();
//            }
//            return monitorUser;
//        }
 
//    }
//}
